FROM centos:7
#更新系统
#RUN yum -y update
#安装ifconfig、netstat、less、vim、which、lrzsz命令
RUN yum -y install net-tools && yum -y install less && yum -y install vim && yum -y install which && yum -y install openssl
#安装ssh 服务端及ssh 客户端
RUN yum -y install openssh-clients && yum -y install openssh-server
#安装修改密码的命令
RUN yum -y install passwd
#清楚
RUN yum clean all
#修改ssh服务端配置
RUN sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
RUN sed -i "s/#UsePrivilegeSeparation.*/UsePrivilegeSeparation no/g" /etc/ssh/sshd_config
#修改root密码
RUN /bin/echo 'root:root' | chpasswd
#生成ssh服务端密钥
RUN ssh-keygen -q -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N ''
RUN ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ''
RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_ed25519_key -N ''
#开放端口
EXPOSE 22
#启动命令
CMD [ "/usr/sbin/sshd","-D"]